-
Notifications
You must be signed in to change notification settings - Fork 44
Time - Jocelyn #23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Time - Jocelyn #23
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very well done. Take a look at my minor comments, but otherwise excellent work.
# Time Complexity: O(n) | ||
# Space Complexity: O(1) | ||
def add_help(current, new_node) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 However since you are using recursion the space complexity is O(log n) if the tree is balanced (time as well) and O(n) if the tree is unbalanced.
# Time Complexity: log(n) | ||
# Space Complexity: O(1) | ||
def help_find(current, key) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 However since you are using recursion the space complexity is O(log n) if the tree is balanced (time as well) and O(n) if the tree is unbalanced.
# Time Complexity: O(n) | ||
# Space Complexity: O(1) | ||
def help_inorder(current) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 However since you are using recursion the space complexity is O(log n) if the tree is balanced and O(n) if the tree is unbalanced.
# Time Complexity: log(n) | ||
# Space Complexity: O(1) | ||
def help_preorder(current) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 However since you are using recursion the space complexity is O(log n) if the tree is balanced and O(n) if the tree is unbalanced.
# Time Complexity: log(n) | ||
# Space Complexity: O(1) | ||
def help_postorder(current) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 However since you are using recursion the space complexity is O(log n) if the tree is balanced and O(n) if the tree is unbalanced.
return 0 if current.nil? | ||
left += height_helper(current.left) | ||
right += height_helper(current.right) | ||
num += 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not just set num to 1 in line 104?
No description provided.